home *** CD-ROM | disk | FTP | other *** search
- ;/* execute me to compile
-
- dcc -ECONSOLE: -proto -pr -mS -mr -l0 -ocapstest capstest.c
- quit
-
- *
- * $VER: CapsTest.c 1.0 (2.12.94)
- *
- * Public Domain by Lauri Aalto <lauri.aalto@fipnet.fi>
- *
- * Reads keyboard matrix and outputs 0/1 depending on caps lock key status.
- */
-
- #include <exec/exec.h>
- #include <dos/dos.h>
- #include <devices/keyboard.h>
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/dos_pragmas.h>
-
- __geta4 void CapsTest() {
- struct Library *SysBase;
- struct Library *DOSBase;
- struct IOStdReq *io;
- struct MsgPort *port;
- char *matrix;
-
- SysBase = *((struct Library **)4);
- if (DOSBase = OpenLibrary("dos.library", 36)) {
- if (port = CreateMsgPort()) {
- if (io = CreateIORequest(port, sizeof(struct IOStdReq))) {
- if (!(OpenDevice("keyboard.device", 0, (struct IORequest *)io, 0))) {
- if (matrix = AllocVec(20, MEMF_PUBLIC | MEMF_CLEAR)) {
- io->io_Command = KBD_READMATRIX;
- io->io_Data = matrix;
- io->io_Length = 20;
- DoIO((struct IORequest *)io);
- if (matrix[12] & (1 << 2)) Write(Output(), "1\n", 2);
- else Write(Output(), "0\n", 2);
- FreeVec(matrix);
- }
- CloseDevice((struct IORequest *)io);
- }
- DeleteIORequest((struct IORequest *)io);
- }
- DeleteMsgPort(port);
- }
- CloseLibrary(DOSBase);
- }
- }
-
- static const char version[] = "\0$VER: CapsTest 1.0 (" __COMMODORE_DATE__ ")";
-